
'''
import os
print(os.path.abspath(__file__))
print(os.path.dirname(os.path.abspath(__file__)))
D:\tensorflow2_pytorch\100道python编程题目练习\26.py
D:\tensorflow2_pytorch\100道python编程题目练习

摄氏度和华氏度转换公式为：
℃ = (℉ - 32) / 1.8 （华氏度转摄氏度）；
℉ = ℃ * 1.8 + 32 （摄氏度转华氏度）。
'''
N = True
while N:
    ForC = input("请输入相应的温度表达(华氏或摄氏):")
    if ForC:
        assert ForC == "华氏" or ForC == "摄氏"
    else:
        raise "输入不能为空"
    try:
       tem = float(input("请输入相应的温度:"))
    except BaseException as e:
        print("%s"%(e))

    if ForC == "华氏":
        C = (tem-32)/1.8
        print("摄氏温度为%f"%(C))
    else:
        F = tem*1.8+32
        print("华氏温度为%f" % (F))

